#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

class Solution
{
public:
    bool validateStackSequences(vector<int>& pushed, vector<int>& popped)
    {
        stack<int> ret;
        int j = 0;
        for (int i = 0; i < pushed.size(); i++)
        {
            ret.push(pushed[i]);
            while (!ret.empty() && ret.top() == popped[j])
            {
                ret.pop();
                j++;
            }
        }
        return ret.empty();
    }
};

int main()
{
    vector<int> v1 = { 1, 0 };
    vector<int> v2 = { 1, 0 };
    Solution s;
    cout << s.validateStackSequences(v1, v2);
    return 0;
}